{extend name="base"}
{block name="resources"/}
{/block}
{block name="body"}
<ol class="breadcrumb">
  <li><a href="#">首页</a></li>
  <li><a href="{:url('system/links')}">友情链接</a></li>
  <li class="active">添加友情链接</li>
</ol>
<form class="form-horizontal" method="post" enctype="multipart/form-data">
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">链接名称</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="link_name" name="link_name" placeholder="链接名称">
      <div class="alert alert-danger none" role="alert">输入名称</div>
    </div>
  </div>
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">链接地址</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="link_url" name="link_url" placeholder="链接地址">
    </div>
  </div>
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">排序</label>
    <div class="col-sm-1">
      <input type="text" class="form-control" id="orderby" name="orderby" placeholder="排序" value="50">
    </div>
  </div>
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">是否新窗口打开</label>
    <div class="col-sm-2">
      <input type="hidden" name="target" value="1">
      <div class="btn-group" role="group" id="select_target">
            <button type="button" class="btn btn-danger" data-id="1">是</button>
            <button type="button" class="btn btn-default" data-id="0">否</button>
      </div>
    </div>
  </div>
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">是否显示</label>
    <div class="col-sm-2">
      <input type="hidden" name="is_show" value="1">
      <div class="btn-group" role="group" id="select_show">
          <button type="button" class="btn btn-danger" data-id="1">是</button>
          <button type="button" class="btn btn-default" data-id="0">否</button>
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-11">
      <button type="submit" class="btn btn-primary" id="submit">确认提交</button>
    </div>
  </div>
  <div class="alert alert-success none" role="alert">修改成功</div>
</form>
<script>
  $('#select_target').on('click','button',function(event) {
    var valId=$(this).attr('data-id');
    $(this).parent('#select_target').siblings('input').val(valId);
    $(this).siblings().removeClass('btn-danger btn-default').end().siblings().addClass('btn-default').end().addClass('btn-danger');
  });
  $('#select_show').on('click','button',function(event) {
    var valId=$(this).attr('data-id');
    $(this).parent('#select_show').siblings('input').val(valId);
    $(this).siblings().removeClass('btn-danger btn-default').end().siblings().addClass('btn-default').end().addClass('btn-danger');
  });
</script>
{/block}